<template>
  <div id="box">
    <el-card class="login">
      <!-- 登录 -->
      <template #header>
        <span class="sp">登录</span>
        <el-form ref="form" label-width="80px">
          <el-form-item label="用户名">
            <el-input v-model="username"></el-input>
          </el-form-item>
          <el-form-item label="密码">
            <el-input v-model="password" type="password"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="login">登录</el-button>
            <el-button>忘记密码</el-button>
          </el-form-item>
        </el-form>
      </template>
    </el-card>
  </div>
</template>

<script>
import { createNamespacedHelpers } from 'vuex';

const { mapActions, mapState, mapMutations } = createNamespacedHelpers('login');

export default {
  data() {
    return {

    };
  },
  computed: {
    ...mapState(['form', 'token']),
    username: {
      get() {
        return this.form.username;
      },
      set(value) {
        this.getUsername(value);
      },
    },
    password: {
      get() {
        return this.form.password;
      },
      set(value) {
        this.getPassword(value);
      },
    },
  },
  methods: {
    ...mapActions(['login']),
    ...mapMutations(['getUsername', 'getPassword']),
  },
};
</script>

<style lang="scss" scoped>
#box{
  width: 1535.5px;
  height: 721px;
  min-width: max-content;
  background: url(../../public/uploads/1.jpg) no-repeat 100%;
  position: relative;
  .login {
    width: 400px;
    position: absolute;
    left: 40%;
    top: 30%;
    background: palegreen;
    border-radius: 6%;
    box-shadow: 10px 10px 5px slategrey;
    font-family: 宋体;
    .sp {
      text-align: center;
      display: block;
      margin: 10px;
      font-size: 20px;
      font-weight: bold;
    };

  }
}
</style>
